let index = 0;
const slideCount = document.querySelectorAll('.slides img').length;
const slides = document.querySelector('.slides');

function goToNextSlide() {
  index = (index + 1) % slideCount;
  const translateXValue = -index * 100 + '%';
  slides.style.transform = `translateX(${translateXValue})`;
}

// 设置自动轮播
setInterval(goToNextSlide, 3000); // 每隔3秒换一张图

// 如果想要手动控制轮播，可以添加按钮并绑定事件处理程序
document.getElementById("next").addEventListener('click', goToNextSlide);